package com.black.cat.jvm.rtda.heap.constantpool;


import com.black.cat.jvm.classfile.constantpool.impl.ConstantInterfaceMethodRefInfo;
import com.black.cat.jvm.rtda.heap.methodarea.JMethod;

public class InterfaceMethodRef extends SymRef {

    private JMethod method;

    public String name;
    public String descriptor;

    public static InterfaceMethodRef newInterfaceMethodRef(RunTimeConstantPool runTimeConstantPool, ConstantInterfaceMethodRefInfo refInfo) {
        InterfaceMethodRef ref = new InterfaceMethodRef();
        ref.runTimeConstantPool = runTimeConstantPool;
        ref.copyMemberRefInfo(refInfo);
        return ref;
    }

    public void copyMemberRefInfo(ConstantInterfaceMethodRefInfo refInfo) {
        this.className = refInfo.getClassName();
        String[] split = refInfo.getNameAndType().split(":");
        this.name = split[0];
        this.descriptor = split[1];
    }

    public JMethod resolvedInterfaceMethod() {
        if (this.method == null) {
            this.resolveInterfaceMethodRef();
        }
        return this.method;
    }

    public void resolveInterfaceMethodRef() {

    }


}
